package com.zhu.classfile.attribute;

import java.nio.ByteBuffer;
/**
 * public void myMethod() throws IOException, SQLException { ... }
 * number_of_exceptions = 2
 * exception_index_table[0] = #5 → IOException
 * exception_index_table[1] = #8 → SQLException
 * 它只记录受检异常（checked exceptions），RuntimeException 不需要声明，所以不会出现在这里。
 *
 * 在 method_info 的属性表中才会出现
 */
public class ExceptionsAttribute implements AttributeInfo {
    // 常量池索引数组
    private  int[] exceptionIndexes;

    @Override
    public void readInfo(ByteBuffer reader) {
        int count = Short.toUnsignedInt(reader.getShort());
        exceptionIndexes = new int[count];
        for (int i = 0; i < count; i++) {
            exceptionIndexes[i] = Short.toUnsignedInt(reader.getShort());
        }
    }
}
